/**
 * Author shuqi
 * Rev
 * Date: 2020-01-01 11:30
 * <p>
 * Copyright (C) 2020 Seeyon, Inc. All rights reserved.
 * <p>
 * This software is the proprietary information of Seeyon, Inc.
 * Use is subject to license terms.
 *
 * @company seeyon.com
 * @since V5 V8.0
 * @author shuqi
 */
package com.shuqi.tools.listeners;

import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
import com.shuqi.tools.CMPHelper;
import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * @date 2020-01-01 11:30
 * @since V5 V8.0
 * @author shuqi
 */
public class SyncFileListener implements BulkFileListener {
	private CMPHelper cmpHelper;
	public SyncFileListener(CMPHelper cmpHelper) {
		this.cmpHelper = cmpHelper;
	}

	@Override
	public void after(@NotNull List<? extends VFileEvent> events) {
		for (VFileEvent event : events) {
			if(event instanceof VFileDeleteEvent){
				continue;
			}
			cmpHelper.syncFile(event.getPath());
		}
	}
}
